package controller.subsystemcom;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import controller.acquaintance.I_WorkCellController_OEE;
import controller.model.WorkCellControllerServer;

public class OEE implements I_WorkCellController_OEE
{
	private static OEE instance;
	private I_WorkCellController_OEE oee;
	
	private OEE()
	{
		try
		{
			oee = (I_WorkCellController_OEE) Naming.lookup(WorkCellControllerServer.rmiOEE);
		}
		catch (MalformedURLException e)
		{ e.printStackTrace(); }
		catch (RemoteException e)
		{ e.printStackTrace(); }
		catch (NotBoundException e)
		{ e.printStackTrace(); }
	}
	
	public static OEE getInstance()
	{
		if (instance == null)
			instance = new OEE();
		return instance;
	}
	
	public int accessBricksUsed(boolean checkAndReset)
	{
		try
		{
			return oee.accessBricksUsed(true);
		}
		catch (RemoteException e)
		{ e.printStackTrace(); }
		
		return 0;
	}

	public int accessBricksEnteredConveyor(boolean checkAndReset)
	{
		try
		{
			return oee.accessBricksEnteredConveyor(true);
		}
		catch (RemoteException e)
		{ e.printStackTrace(); }
		
		return 0;
	}
}
